home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes reversed ƒ / Pour scroll reversed.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  114 lines

  1. /**********************************************************************\
  2.  
  3. File:        Pour scroll reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short PourScrollReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Scroll down in tiny strips, starting at the right and moving left.  Scroll
  34.    strips 1-(N), then strips 1-(N+1), etc.  When strip 1 is done, don't do it
  35.    anymore!  (Duh, but this was difficult to get right.)  So only scroll strips
  36.    2-(N), and so on. */
  37.    
  38. pascal short PourScrollReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  39. {
  40.     Rect            *theRect, *dest;
  41.     Rect            scrollsource;
  42.     int                i;
  43.     int                startstrip,endstrip;
  44.     int                ScrollSize, BoxSize;
  45.     int                NumStrips;
  46.     
  47.     ScrollSize=theWindowHeight/50;
  48.     NumStrips=theWindowWidth/4;
  49.     BoxSize=theWindowWidth/NumStrips;
  50.     dest=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  51.     if (dest==0L)
  52.         return -1;        /* memory error */
  53.     theRect=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  54.     if (theRect==0L)
  55.     {
  56.         DisposePtr(dest);
  57.         return -1;        /* memory error */
  58.     }
  59.     
  60.     SetRect(&scrollsource, boundsRect.right-BoxSize, boundsRect.top,
  61.         boundsRect.right, boundsRect.bottom);
  62.         
  63.     for (i=0; i<NumStrips; i++)
  64.     {
  65.         dest[i].top = theWindowHeight-ScrollSize;
  66.         dest[i].bottom=theWindowHeight;
  67.         dest[i].left=theWindowWidth-(i+1)*BoxSize;
  68.         dest[i].right=dest[i].left+BoxSize;
  69.         OffsetRect(&(dest[i]), boundsRect.left, boundsRect.top);
  70.         
  71.         theRect[i].top=0;
  72.         theRect[i].bottom=ScrollSize;
  73.         theRect[i].left=theWindowWidth-(i+1)*BoxSize;
  74.         theRect[i].right=theRect[i].left+BoxSize;
  75.         OffsetRect(&(theRect[i]), boundsRect.left, boundsRect.top);
  76.     }
  77.     
  78.     startstrip=0;
  79.     endstrip=1;
  80.     do
  81.     {
  82.         StartTiming();
  83.         
  84.         ScrollTheRect(&scrollsource, 0, -ScrollSize, 0L);
  85.         
  86.         for (i=startstrip; i<endstrip; i++)
  87.         {
  88.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  89.                     &theRect[i], &dest[i], 0, 0L);
  90.             theRect[i].bottom+=ScrollSize;
  91.             theRect[i].top+=ScrollSize;
  92.         }
  93.         
  94.         if (endstrip<NumStrips)
  95.         {
  96.             endstrip++;
  97.             scrollsource.left-=BoxSize;
  98.         }
  99.         if (theRect[startstrip].top>=theWindowHeight)
  100.         {
  101.             startstrip++;
  102.             scrollsource.right-=BoxSize;
  103.         }
  104.         
  105.         TimeCorrection(CorrectTime);
  106.     }
  107.     while (startstrip<endstrip);
  108.     
  109.     DisposePtr(dest);
  110.     DisposePtr(theRect);
  111.     
  112.     return 0;
  113. }
  114.